package cn.kgc.crowdfundingadmin.service;


import cn.kgc.crowdfundingadmin.mapper.MessageMapper;
import cn.kgc.crowdfundingadmin.pojo.Message;
import cn.kgc.crowdfundingadmin.pojo.MessageExample;
import cn.kgc.crowdfundingadmin.pojo.RoleExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {
    @Resource
    MessageMapper messageMapper;
    @Override
    public PageInfo<Message> queryForKeywordWithPage(Integer pageNum, Integer pageSize, String keyword) {
        // 1.开启分页功能
        PageHelper.startPage(pageNum, pageSize);

        // 2.执行查询
        MessageExample messageExample=new MessageExample();
        MessageExample.Criteria criteria = messageExample.createCriteria();
       criteria.andContentLike("%"+keyword+"%");
        List<Message> list = messageMapper.selectByExample(messageExample);
        // 3.封装为PageInfo对象
        return new PageInfo<>(list);
    }
    }

